{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from QIFIAccount import QIFI_Account, ORDER_DIRECTION"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=QIFI_Account('c575cf42-7138-494d-a712-38ea3227a511','d524154a-702c-40b8-a23d-829226fc3fd8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "a.reload()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "#a.make_deal(a.send_order('RB2001', 10, 4200, ORDER_DIRECTION.BUY_OPEN))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'code': '000001',\n",
       " 'instrument_id': '000001',\n",
       " 'user_id': 'quantaxis',\n",
       " 'portfolio_cookie': 'portfolio',\n",
       " 'username': 'quantaxis',\n",
       " 'position_id': '36175834-78d5-4e9c-8298-15e9bd9df618',\n",
       " 'account_cookie': 'quantaxis',\n",
       " 'frozen': {},\n",
       " 'name': None,\n",
       " 'spms_id': None,\n",
       " 'oms_id': None,\n",
       " 'market_type': 'stock_cn',\n",
       " 'exchange_id': None,\n",
       " 'moneypreset': 100000,\n",
       " 'moneypresetLeft': 100000,\n",
       " 'lastupdatetime': '',\n",
       " 'volume_long_today': 10.0,\n",
       " 'volume_long_his': 0,\n",
       " 'volume_long': 10.0,\n",
       " 'volume_short_today': 0,\n",
       " 'volume_short_his': 0,\n",
       " 'volume_short': 0,\n",
       " 'volume_long_frozen_today': 0,\n",
       " 'volume_long_frozen_his': 0,\n",
       " 'volume_long_frozen': 0,\n",
       " 'volume_short_frozen_today': 0,\n",
       " 'volume_short_frozen_his': 0,\n",
       " 'volume_short_frozen': 0,\n",
       " 'margin_long': 118.0,\n",
       " 'margin_short': 0,\n",
       " 'margin': 118.0,\n",
       " 'position_price_long': 11.8,\n",
       " 'position_cost_long': 118.0,\n",
       " 'position_price_short': 0,\n",
       " 'position_cost_short': 0,\n",
       " 'open_price_long': 11.8,\n",
       " 'open_cost_long': 118.0,\n",
       " 'open_price_short': 0,\n",
       " 'open_cost_short': 0,\n",
       " 'trades': [],\n",
       " 'orders': {},\n",
       " 'last_price': 11.8,\n",
       " 'float_profit_long': 0.0,\n",
       " 'float_profit_short': 0.0,\n",
       " 'float_profit': 0.0,\n",
       " 'position_profit_long': 0.0,\n",
       " 'position_profit_short': 0.0,\n",
       " 'position_profit': 0.0}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.positions['000001'].message"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.positions['RB2001'].float_profit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.positions['RB2001'].position_profit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'code': 'RB2001',\n",
       " 'instrument_id': 'RB2001',\n",
       " 'user_id': 'quantaxis',\n",
       " 'portfolio_cookie': 'portfolio',\n",
       " 'username': 'quantaxis',\n",
       " 'position_id': '5820fd1b-e3cc-4aac-bf8c-a0935751a24d',\n",
       " 'account_cookie': 'quantaxis',\n",
       " 'frozen': {},\n",
       " 'name': None,\n",
       " 'spms_id': None,\n",
       " 'oms_id': None,\n",
       " 'market_type': 'stock_cn',\n",
       " 'exchange_id': None,\n",
       " 'moneypreset': 100000,\n",
       " 'moneypresetLeft': -51200.0,\n",
       " 'lastupdatetime': '',\n",
       " 'volume_long_today': 40.0,\n",
       " 'volume_long_his': 0,\n",
       " 'volume_long': 40.0,\n",
       " 'volume_short_today': 0,\n",
       " 'volume_short_his': 0,\n",
       " 'volume_short': 0,\n",
       " 'volume_long_frozen_today': 0,\n",
       " 'volume_long_frozen_his': 0,\n",
       " 'volume_long_frozen': 0,\n",
       " 'volume_short_frozen_today': 0,\n",
       " 'volume_short_frozen_his': 0,\n",
       " 'volume_short_frozen': 0,\n",
       " 'margin_long': 151200.0,\n",
       " 'margin_short': 0,\n",
       " 'margin': 151200.0,\n",
       " 'position_price_long': 4200.0,\n",
       " 'position_cost_long': 1680000.0,\n",
       " 'position_price_short': 0,\n",
       " 'position_cost_short': 0,\n",
       " 'open_price_long': 4200.0,\n",
       " 'open_cost_long': 1680000.0,\n",
       " 'open_price_short': 0,\n",
       " 'open_cost_short': 0,\n",
       " 'trades': [],\n",
       " 'orders': {},\n",
       " 'last_price': 4200.0,\n",
       " 'float_profit_long': 0.0,\n",
       " 'float_profit_short': 0.0,\n",
       " 'float_profit': 0.0,\n",
       " 'position_profit_long': 0.0,\n",
       " 'position_profit_short': 0.0,\n",
       " 'position_profit': 0.0}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.positions['RB2001'].message"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000032.0"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.balance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'password': 'd524154a-702c-40b8-a23d-829226fc3fd8', 'databaseip': '', 'model': 'SIM', 'ping_gap': 5, 'portfolio': 'QAPaperTrade', 'broker_name': 'QAPaperTrading', 'capital_password': '', 'bank_password': '', 'bankid': 'QASIM', 'investor_name': '', 'money': 803682.0, 'pub_host': '', 'trade_host': '', 'taskid': '', 'sourceid': 'QIFI_Account', 'updatetime': '', 'wsuri': 'ws://www.yutiansut.com:7988', 'bankname': 'QASIMBank', 'trading_day': '2019-10-09', 'status': 200, 'accounts': {'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'currency': 'CNY', 'pre_balance': 0, 'deposit': 1000000, 'withdraw': 0, 'WithdrawQuota': 0, 'close_profit': 0, 'commission': 0, 'premium': None, 'static_balance': 0, 'position_profit': 19981.0, 'float_profit': 19981.0, 'balance': 1019981.0, 'margin': 151318.0, 'frozen_margin': 0, 'frozen_commission': 0.0, 'frozen_premium': 0.0, 'available': 803682.0, 'risk_ratio': 0.21206179330791453}, 'trades': {'5c3710e5-7f0c-4dd1-b029-739a5f2ab332': {'seqno': 2, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '5c3710e5-7f0c-4dd1-b029-739a5f2ab332', 'exchange_id': None, 'instrument_id': '000001', 'order_id': '082d06e7-327c-40ab-8289-4366a458d210', 'exchange_trade_id': '5c3710e5-7f0c-4dd1-b029-739a5f2ab332', 'direction': 'BUY', 'offset': '', 'volume': 10.0, 'price': 11.8, 'trade_date_time': '2019-10-09 00:07:39.687263'}, '3678db90-5f55-4928-a4c1-2d113c972efb': {'seqno': 3, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '3678db90-5f55-4928-a4c1-2d113c972efb', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': '6eb007ec-0eb4-4176-a11e-ed09440240d3', 'exchange_trade_id': '3678db90-5f55-4928-a4c1-2d113c972efb', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:02:57.337506'}, '7097c914-b561-4923-87d9-4d5792916ebe': {'seqno': 2, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '7097c914-b561-4923-87d9-4d5792916ebe', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': '0c7df333-d7be-43aa-8d8f-8323a547895c', 'exchange_trade_id': '7097c914-b561-4923-87d9-4d5792916ebe', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:04:07.482498'}, '7509f8bb-bd11-45bd-bfe8-4ebbe5398df9': {'seqno': 2, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '7509f8bb-bd11-45bd-bfe8-4ebbe5398df9', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': 'a95b3f35-223a-4db6-89ce-392360b49dda', 'exchange_trade_id': '7509f8bb-bd11-45bd-bfe8-4ebbe5398df9', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:05:17.524504'}, 'e12ea96d-9a25-43f9-87e2-eb50c68e1198': {'seqno': 4, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': 'e12ea96d-9a25-43f9-87e2-eb50c68e1198', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': '365554db-81d9-4fd4-a300-265d00d848d1', 'exchange_trade_id': 'e12ea96d-9a25-43f9-87e2-eb50c68e1198', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:07:54.557777'}}, 'positions': {'000001': {'code': '000001', 'instrument_id': '000001', 'user_id': 'quantaxis', 'portfolio_cookie': 'portfolio', 'username': 'quantaxis', 'position_id': '36175834-78d5-4e9c-8298-15e9bd9df618', 'account_cookie': 'quantaxis', 'frozen': {}, 'name': None, 'spms_id': None, 'oms_id': None, 'market_type': 'stock_cn', 'exchange_id': None, 'moneypreset': 100000, 'moneypresetLeft': 100000, 'lastupdatetime': '', 'volume_long_today': 10.0, 'volume_long_his': 0, 'volume_long': 10.0, 'volume_short_today': 0, 'volume_short_his': 0, 'volume_short': 0, 'volume_long_frozen_today': 0, 'volume_long_frozen_his': 0, 'volume_long_frozen': 0, 'volume_short_frozen_today': 0, 'volume_short_frozen_his': 0, 'volume_short_frozen': 0, 'margin_long': 118.0, 'margin_short': 0, 'margin': 118.0, 'position_price_long': 11.8, 'position_cost_long': 118.0, 'position_price_short': 0, 'position_cost_short': 0, 'open_price_long': 11.8, 'open_cost_long': 118.0, 'open_price_short': 0, 'open_cost_short': 0, 'trades': [], 'orders': {}, 'last_price': 9.9, 'float_profit_long': -19.0, 'float_profit_short': 0.0, 'float_profit': -19.0, 'position_profit_long': -19.0, 'position_profit_short': 0.0, 'position_profit': -19.0}, 'RB2001': {'code': 'RB2001', 'instrument_id': 'RB2001', 'user_id': 'quantaxis', 'portfolio_cookie': 'portfolio', 'username': 'quantaxis', 'position_id': '5820fd1b-e3cc-4aac-bf8c-a0935751a24d', 'account_cookie': 'quantaxis', 'frozen': {}, 'name': None, 'spms_id': None, 'oms_id': None, 'market_type': 'stock_cn', 'exchange_id': None, 'moneypreset': 100000, 'moneypresetLeft': -51200.0, 'lastupdatetime': '', 'volume_long_today': 40.0, 'volume_long_his': 0, 'volume_long': 40.0, 'volume_short_today': 0, 'volume_short_his': 0, 'volume_short': 0, 'volume_long_frozen_today': 0, 'volume_long_frozen_his': 0, 'volume_long_frozen': 0, 'volume_short_frozen_today': 0, 'volume_short_frozen_his': 0, 'volume_short_frozen': 0, 'margin_long': 151200.0, 'margin_short': 0, 'margin': 151200.0, 'position_price_long': 4200.0, 'position_cost_long': 1680000.0, 'position_price_short': 0, 'position_cost_short': 0, 'open_price_long': 4200.0, 'open_cost_long': 1680000.0, 'open_price_short': 0, 'open_cost_short': 0, 'trades': [], 'orders': {}, 'last_price': 4250, 'float_profit_long': 20000.0, 'float_profit_short': 0, 'float_profit': 20000.0, 'position_profit_long': 20000.0, 'position_profit_short': 0, 'position_profit': 20000.0}}, 'orders': {'082d06e7-327c-40ab-8289-4366a458d210': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': '000001', 'towards': 1, 'exchange_id': None, 'order_time': '2019-10-09 00:07:39.686197', 'volume': 10.0, 'price': 12.0, 'order_id': '082d06e7-327c-40ab-8289-4366a458d210', 'seqno': 1, 'direction': 'BUY', 'offset': '', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 12.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 00:07:39.686197', 'exchange_order_id': '731edf74-3230-44d5-9f8a-582d3c196f60', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, 'aa60a8c4-f8ba-4174-a6b6-cb20ac8e0c51': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:01:49.728069', 'volume': 10.0, 'price': 5000.0, 'order_id': 'aa60a8c4-f8ba-4174-a6b6-cb20ac8e0c51', 'seqno': 1, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 5000.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:01:49.728069', 'exchange_order_id': '84fd36d6-4d0a-4e29-905c-5bd1dcc7bbb9', 'status': 100, 'volume_left': 10.0, 'last_msg': '已报'}, '6eb007ec-0eb4-4176-a11e-ed09440240d3': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:02:57.337457', 'volume': 10.0, 'price': 4200.0, 'order_id': '6eb007ec-0eb4-4176-a11e-ed09440240d3', 'seqno': 2, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:02:57.337506', 'exchange_order_id': '6a5047c4-1d0d-4f68-ba4a-7a72cca72c50', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, '0c7df333-d7be-43aa-8d8f-8323a547895c': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:04:07.482498', 'volume': 10.0, 'price': 4200.0, 'order_id': '0c7df333-d7be-43aa-8d8f-8323a547895c', 'seqno': 1, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:04:07.482498', 'exchange_order_id': '5fcca26e-0d64-4877-9b18-1a61caa8f20a', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, 'a95b3f35-223a-4db6-89ce-392360b49dda': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:05:17.524504', 'volume': 10.0, 'price': 4200.0, 'order_id': 'a95b3f35-223a-4db6-89ce-392360b49dda', 'seqno': 1, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:05:17.524504', 'exchange_order_id': '36e5642a-ec52-4c32-8150-72fcb76bf518', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, '365554db-81d9-4fd4-a300-265d00d848d1': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:07:54.557777', 'volume': 10.0, 'price': 4200.0, 'order_id': '365554db-81d9-4fd4-a300-265d00d848d1', 'seqno': 3, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:07:54.557777', 'exchange_order_id': 'c9ee990a-ecc1-45e6-929f-60522568592e', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}}, 'events': {'2019-10-09 00:07:39.604215': '转账成功 1000000', '2019-10-09 00:07:39.687263': '全部成交 082d06e7-327c-40ab-8289-4366a458d210', '2019-10-09 01:02:57.337506': '全部成交 6eb007ec-0eb4-4176-a11e-ed09440240d3', '2019-10-09 01:04:07.482498': '全部成交 0c7df333-d7be-43aa-8d8f-8323a547895c', '2019-10-09 01:05:17.524504': '全部成交 a95b3f35-223a-4db6-89ce-392360b49dda', '2019-10-09 01:07:54.557777': '全部成交 365554db-81d9-4fd4-a300-265d00d848d1'}, 'transfers': {'0': {'datetime': 433241234123, 'currency': 'CNY', 'amount': 1000000, 'error_id': 0, 'error_msg': '成功'}}, 'banks': {'QASIM': {'id': 'QASIM', 'name': 'QASIMBank', 'bank_account': '', 'fetch_amount': 0.0, 'qry_count': 0}}, 'settlement': {}}"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "a.on_price_change('000001', 9.9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'password': 'd524154a-702c-40b8-a23d-829226fc3fd8', 'databaseip': '', 'model': 'SIM', 'ping_gap': 5, 'portfolio': 'QAPaperTrade', 'broker_name': 'QAPaperTrading', 'capital_password': '', 'bank_password': '', 'bankid': 'QASIM', 'investor_name': '', 'money': 803682.0, 'pub_host': '', 'trade_host': '', 'taskid': '', 'sourceid': 'QIFI_Account', 'updatetime': '', 'wsuri': 'ws://www.yutiansut.com:7988', 'bankname': 'QASIMBank', 'trading_day': '2019-10-09', 'status': 200, 'accounts': {'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'currency': 'CNY', 'pre_balance': 0, 'deposit': 1000000, 'withdraw': 0, 'WithdrawQuota': 0, 'close_profit': 0, 'commission': 0, 'premium': None, 'static_balance': 0, 'position_profit': 20032.0, 'float_profit': 20032.0, 'balance': 1020032.0, 'margin': 151318.0, 'frozen_margin': 0, 'frozen_commission': 0.0, 'frozen_premium': 0.0, 'available': 803682.0, 'risk_ratio': 0.21210118898230645}, 'trades': {'5c3710e5-7f0c-4dd1-b029-739a5f2ab332': {'seqno': 2, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '5c3710e5-7f0c-4dd1-b029-739a5f2ab332', 'exchange_id': None, 'instrument_id': '000001', 'order_id': '082d06e7-327c-40ab-8289-4366a458d210', 'exchange_trade_id': '5c3710e5-7f0c-4dd1-b029-739a5f2ab332', 'direction': 'BUY', 'offset': '', 'volume': 10.0, 'price': 11.8, 'trade_date_time': '2019-10-09 00:07:39.687263'}, '3678db90-5f55-4928-a4c1-2d113c972efb': {'seqno': 3, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '3678db90-5f55-4928-a4c1-2d113c972efb', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': '6eb007ec-0eb4-4176-a11e-ed09440240d3', 'exchange_trade_id': '3678db90-5f55-4928-a4c1-2d113c972efb', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:02:57.337506'}, '7097c914-b561-4923-87d9-4d5792916ebe': {'seqno': 2, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '7097c914-b561-4923-87d9-4d5792916ebe', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': '0c7df333-d7be-43aa-8d8f-8323a547895c', 'exchange_trade_id': '7097c914-b561-4923-87d9-4d5792916ebe', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:04:07.482498'}, '7509f8bb-bd11-45bd-bfe8-4ebbe5398df9': {'seqno': 2, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': '7509f8bb-bd11-45bd-bfe8-4ebbe5398df9', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': 'a95b3f35-223a-4db6-89ce-392360b49dda', 'exchange_trade_id': '7509f8bb-bd11-45bd-bfe8-4ebbe5398df9', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:05:17.524504'}, 'e12ea96d-9a25-43f9-87e2-eb50c68e1198': {'seqno': 4, 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'trade_id': 'e12ea96d-9a25-43f9-87e2-eb50c68e1198', 'exchange_id': 'SHFE', 'instrument_id': 'RB2001', 'order_id': '365554db-81d9-4fd4-a300-265d00d848d1', 'exchange_trade_id': 'e12ea96d-9a25-43f9-87e2-eb50c68e1198', 'direction': 'BUY', 'offset': 'OPEN', 'volume': 10.0, 'price': 4200.0, 'trade_date_time': '2019-10-09 01:07:54.557777'}}, 'positions': {'000001': {'code': '000001', 'instrument_id': '000001', 'user_id': 'quantaxis', 'portfolio_cookie': 'portfolio', 'username': 'quantaxis', 'position_id': '36175834-78d5-4e9c-8298-15e9bd9df618', 'account_cookie': 'quantaxis', 'frozen': {}, 'name': None, 'spms_id': None, 'oms_id': None, 'market_type': 'stock_cn', 'exchange_id': None, 'moneypreset': 100000, 'moneypresetLeft': 100000, 'lastupdatetime': '', 'volume_long_today': 10.0, 'volume_long_his': 0, 'volume_long': 10.0, 'volume_short_today': 0, 'volume_short_his': 0, 'volume_short': 0, 'volume_long_frozen_today': 0, 'volume_long_frozen_his': 0, 'volume_long_frozen': 0, 'volume_short_frozen_today': 0, 'volume_short_frozen_his': 0, 'volume_short_frozen': 0, 'margin_long': 118.0, 'margin_short': 0, 'margin': 118.0, 'position_price_long': 11.8, 'position_cost_long': 118.0, 'position_price_short': 0, 'position_cost_short': 0, 'open_price_long': 11.8, 'open_cost_long': 118.0, 'open_price_short': 0, 'open_cost_short': 0, 'trades': [], 'orders': {}, 'last_price': 15, 'float_profit_long': 32.0, 'float_profit_short': 0, 'float_profit': 32.0, 'position_profit_long': 32.0, 'position_profit_short': 0, 'position_profit': 32.0}, 'RB2001': {'code': 'RB2001', 'instrument_id': 'RB2001', 'user_id': 'quantaxis', 'portfolio_cookie': 'portfolio', 'username': 'quantaxis', 'position_id': '5820fd1b-e3cc-4aac-bf8c-a0935751a24d', 'account_cookie': 'quantaxis', 'frozen': {}, 'name': None, 'spms_id': None, 'oms_id': None, 'market_type': 'stock_cn', 'exchange_id': None, 'moneypreset': 100000, 'moneypresetLeft': -51200.0, 'lastupdatetime': '', 'volume_long_today': 40.0, 'volume_long_his': 0, 'volume_long': 40.0, 'volume_short_today': 0, 'volume_short_his': 0, 'volume_short': 0, 'volume_long_frozen_today': 0, 'volume_long_frozen_his': 0, 'volume_long_frozen': 0, 'volume_short_frozen_today': 0, 'volume_short_frozen_his': 0, 'volume_short_frozen': 0, 'margin_long': 151200.0, 'margin_short': 0, 'margin': 151200.0, 'position_price_long': 4200.0, 'position_cost_long': 1680000.0, 'position_price_short': 0, 'position_cost_short': 0, 'open_price_long': 4200.0, 'open_cost_long': 1680000.0, 'open_price_short': 0, 'open_cost_short': 0, 'trades': [], 'orders': {}, 'last_price': 4250, 'float_profit_long': 20000.0, 'float_profit_short': 0, 'float_profit': 20000.0, 'position_profit_long': 20000.0, 'position_profit_short': 0, 'position_profit': 20000.0}}, 'orders': {'082d06e7-327c-40ab-8289-4366a458d210': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': '000001', 'towards': 1, 'exchange_id': None, 'order_time': '2019-10-09 00:07:39.686197', 'volume': 10.0, 'price': 12.0, 'order_id': '082d06e7-327c-40ab-8289-4366a458d210', 'seqno': 1, 'direction': 'BUY', 'offset': '', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 12.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 00:07:39.686197', 'exchange_order_id': '731edf74-3230-44d5-9f8a-582d3c196f60', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, 'aa60a8c4-f8ba-4174-a6b6-cb20ac8e0c51': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:01:49.728069', 'volume': 10.0, 'price': 5000.0, 'order_id': 'aa60a8c4-f8ba-4174-a6b6-cb20ac8e0c51', 'seqno': 1, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 5000.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:01:49.728069', 'exchange_order_id': '84fd36d6-4d0a-4e29-905c-5bd1dcc7bbb9', 'status': 100, 'volume_left': 10.0, 'last_msg': '已报'}, '6eb007ec-0eb4-4176-a11e-ed09440240d3': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:02:57.337457', 'volume': 10.0, 'price': 4200.0, 'order_id': '6eb007ec-0eb4-4176-a11e-ed09440240d3', 'seqno': 2, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:02:57.337506', 'exchange_order_id': '6a5047c4-1d0d-4f68-ba4a-7a72cca72c50', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, '0c7df333-d7be-43aa-8d8f-8323a547895c': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:04:07.482498', 'volume': 10.0, 'price': 4200.0, 'order_id': '0c7df333-d7be-43aa-8d8f-8323a547895c', 'seqno': 1, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:04:07.482498', 'exchange_order_id': '5fcca26e-0d64-4877-9b18-1a61caa8f20a', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, 'a95b3f35-223a-4db6-89ce-392360b49dda': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:05:17.524504', 'volume': 10.0, 'price': 4200.0, 'order_id': 'a95b3f35-223a-4db6-89ce-392360b49dda', 'seqno': 1, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:05:17.524504', 'exchange_order_id': '36e5642a-ec52-4c32-8150-72fcb76bf518', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}, '365554db-81d9-4fd4-a300-265d00d848d1': {'account_cookie': 'c575cf42-7138-494d-a712-38ea3227a511', 'user_id': 'c575cf42-7138-494d-a712-38ea3227a511', 'instrument_id': 'RB2001', 'towards': 2, 'exchange_id': 'SHFE', 'order_time': '2019-10-09 01:07:54.557777', 'volume': 10.0, 'price': 4200.0, 'order_id': '365554db-81d9-4fd4-a300-265d00d848d1', 'seqno': 3, 'direction': 'BUY', 'offset': 'OPEN', 'volume_orign': 10.0, 'price_type': 'LIMIT', 'limit_price': 4200.0, 'time_condition': 'GFD', 'volume_condition': 'ANY', 'insert_date_time': '2019-10-09 01:07:54.557777', 'exchange_order_id': 'c9ee990a-ecc1-45e6-929f-60522568592e', 'status': 300, 'volume_left': 0.0, 'last_msg': '全部成交'}}, 'events': {'2019-10-09 00:07:39.604215': '转账成功 1000000', '2019-10-09 00:07:39.687263': '全部成交 082d06e7-327c-40ab-8289-4366a458d210', '2019-10-09 01:02:57.337506': '全部成交 6eb007ec-0eb4-4176-a11e-ed09440240d3', '2019-10-09 01:04:07.482498': '全部成交 0c7df333-d7be-43aa-8d8f-8323a547895c', '2019-10-09 01:05:17.524504': '全部成交 a95b3f35-223a-4db6-89ce-392360b49dda', '2019-10-09 01:07:54.557777': '全部成交 365554db-81d9-4fd4-a300-265d00d848d1'}, 'transfers': {'0': {'datetime': 433241234123, 'currency': 'CNY', 'amount': 1000000, 'error_id': 0, 'error_msg': '成功'}}, 'banks': {'QASIM': {'id': 'QASIM', 'name': 'QASIMBank', 'bank_account': '', 'fetch_amount': 0.0, 'qry_count': 0}}, 'settlement': {}}"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "a.on_price_change('RB2001', 4250)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
